\(\int \sqrt {a+b \cot ^2(c+d x)} \, dx\) [33]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [F(-2)]
   Giac [F(-2)]
   Mupad [F(-1)]

Optimal result

Integrand size = 16, antiderivative size = 87 \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=-\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d}-\frac {\sqrt {b} \text {arctanh}\left (\frac {\sqrt {b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d} \]

[Out]

-arctan(cot(d*x+c)*(a-b)^(1/2)/(a+b*cot(d*x+c)^2)^(1/2))*(a-b)^(1/2)/d-arctanh(cot(d*x+c)*b^(1/2)/(a+b*cot(d*x
+c)^2)^(1/2))*b^(1/2)/d

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 87, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.375, Rules used = {3742, 399, 223, 212, 385, 209} \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=-\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d}-\frac {\sqrt {b} \text {arctanh}\left (\frac {\sqrt {b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d} \]

[In]

Int[Sqrt[a + b*Cot[c + d*x]^2],x]

[Out]

-((Sqrt[a - b]*ArcTan[(Sqrt[a - b]*Cot[c + d*x])/Sqrt[a + b*Cot[c + d*x]^2]])/d) - (Sqrt[b]*ArcTanh[(Sqrt[b]*C
ot[c + d*x])/Sqrt[a + b*Cot[c + d*x]^2]])/d

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 223

Int[1/Sqrt[(a_) + (b_.)*(x_)^2], x_Symbol] :> Subst[Int[1/(1 - b*x^2), x], x, x/Sqrt[a + b*x^2]] /; FreeQ[{a,
b}, x] &&  !GtQ[a, 0]

Rule 385

Int[((a_) + (b_.)*(x_)^(n_))^(p_)/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Subst[Int[1/(c - (b*c - a*d)*x^n), x]
, x, x/(a + b*x^n)^(1/n)] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && EqQ[n*p + 1, 0] && IntegerQ[n]

Rule 399

Int[((a_) + (b_.)*(x_)^(n_))^(p_)/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Dist[b/d, Int[(a + b*x^n)^(p - 1), x]
, x] - Dist[(b*c - a*d)/d, Int[(a + b*x^n)^(p - 1)/(c + d*x^n), x], x] /; FreeQ[{a, b, c, d, p}, x] && NeQ[b*c
 - a*d, 0] && EqQ[n*(p - 1) + 1, 0] && IntegerQ[n]

Rule 3742

Int[((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x]
, x]}, Dist[c*(ff/f), Subst[Int[(a + b*(ff*x)^n)^p/(c^2 + ff^2*x^2), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ
[{a, b, c, e, f, n, p}, x] && (IntegersQ[n, p] || IGtQ[p, 0] || EqQ[n^2, 4] || EqQ[n^2, 16])

Rubi steps \begin{align*} \text {integral}& = -\frac {\text {Subst}\left (\int \frac {\sqrt {a+b x^2}}{1+x^2} \, dx,x,\cot (c+d x)\right )}{d} \\ & = -\frac {(a-b) \text {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (c+d x)\right )}{d}-\frac {b \text {Subst}\left (\int \frac {1}{\sqrt {a+b x^2}} \, dx,x,\cot (c+d x)\right )}{d} \\ & = -\frac {(a-b) \text {Subst}\left (\int \frac {1}{1-(-a+b) x^2} \, dx,x,\frac {\cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d}-\frac {b \text {Subst}\left (\int \frac {1}{1-b x^2} \, dx,x,\frac {\cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d} \\ & = -\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d}-\frac {\sqrt {b} \text {arctanh}\left (\frac {\sqrt {b} \cot (c+d x)}{\sqrt {a+b \cot ^2(c+d x)}}\right )}{d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.08 (sec) , antiderivative size = 107, normalized size of antiderivative = 1.23 \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\frac {\sqrt {a-b} \arctan \left (\frac {\sqrt {b}+\sqrt {b} \cot ^2(c+d x)-\cot (c+d x) \sqrt {a+b \cot ^2(c+d x)}}{\sqrt {a-b}}\right )+\sqrt {b} \log \left (-\sqrt {b} \cot (c+d x)+\sqrt {a+b \cot ^2(c+d x)}\right )}{d} \]

[In]

Integrate[Sqrt[a + b*Cot[c + d*x]^2],x]

[Out]

(Sqrt[a - b]*ArcTan[(Sqrt[b] + Sqrt[b]*Cot[c + d*x]^2 - Cot[c + d*x]*Sqrt[a + b*Cot[c + d*x]^2])/Sqrt[a - b]]
+ Sqrt[b]*Log[-(Sqrt[b]*Cot[c + d*x]) + Sqrt[a + b*Cot[c + d*x]^2]])/d

Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(169\) vs. \(2(75)=150\).

Time = 0.05 (sec) , antiderivative size = 170, normalized size of antiderivative = 1.95

method result size
derivativedivides \(-\frac {\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (d x +c \right )+\sqrt {a +b \cot \left (d x +c \right )^{2}}\right )}{d}+\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d b \left (a -b \right )}-\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d \,b^{2} \left (a -b \right )}\) \(170\)
default \(-\frac {\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (d x +c \right )+\sqrt {a +b \cot \left (d x +c \right )^{2}}\right )}{d}+\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d b \left (a -b \right )}-\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (d x +c \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (d x +c \right )^{2}}}\right )}{d \,b^{2} \left (a -b \right )}\) \(170\)

[In]

int((a+b*cot(d*x+c)^2)^(1/2),x,method=_RETURNVERBOSE)

[Out]

-1/d*b^(1/2)*ln(b^(1/2)*cot(d*x+c)+(a+b*cot(d*x+c)^2)^(1/2))+1/d*(b^4*(a-b))^(1/2)/b/(a-b)*arctan(b^2*(a-b)/(b
^4*(a-b))^(1/2)/(a+b*cot(d*x+c)^2)^(1/2)*cot(d*x+c))-1/d*a*(b^4*(a-b))^(1/2)/b^2/(a-b)*arctan(b^2*(a-b)/(b^4*(
a-b))^(1/2)/(a+b*cot(d*x+c)^2)^(1/2)*cot(d*x+c))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 169 vs. \(2 (75) = 150\).

Time = 0.30 (sec) , antiderivative size = 703, normalized size of antiderivative = 8.08 \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\left [\frac {\sqrt {-a + b} \log \left (-{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) + \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right ) + b\right ) + \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, d x + 2 \, c\right ) + 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right ) - a - 2 \, b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}\right )}{2 \, d}, -\frac {2 \, \sqrt {a - b} \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right )}{{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) + a - b}\right ) - \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, d x + 2 \, c\right ) + 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right ) - a - 2 \, b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}\right )}{2 \, d}, \frac {2 \, \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right )}{b \cos \left (2 \, d x + 2 \, c\right ) + b}\right ) + \sqrt {-a + b} \log \left (-{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) + \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right ) + b\right )}{2 \, d}, -\frac {\sqrt {a - b} \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right )}{{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) + a - b}\right ) - \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, d x + 2 \, c\right ) - a - b}{\cos \left (2 \, d x + 2 \, c\right ) - 1}} \sin \left (2 \, d x + 2 \, c\right )}{b \cos \left (2 \, d x + 2 \, c\right ) + b}\right )}{d}\right ] \]

[In]

integrate((a+b*cot(d*x+c)^2)^(1/2),x, algorithm="fricas")

[Out]

[1/2*(sqrt(-a + b)*log(-(a - b)*cos(2*d*x + 2*c) + sqrt(-a + b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2
*d*x + 2*c) - 1))*sin(2*d*x + 2*c) + b) + sqrt(b)*log(((a - 2*b)*cos(2*d*x + 2*c) + 2*sqrt(b)*sqrt(((a - b)*co
s(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) - a - 2*b)/(cos(2*d*x + 2*c) - 1)))/d, -1/2*(
2*sqrt(a - b)*arctan(-sqrt(a - b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x +
2*c)/((a - b)*cos(2*d*x + 2*c) + a - b)) - sqrt(b)*log(((a - 2*b)*cos(2*d*x + 2*c) + 2*sqrt(b)*sqrt(((a - b)*c
os(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) - a - 2*b)/(cos(2*d*x + 2*c) - 1)))/d, 1/2*(
2*sqrt(-b)*arctan(sqrt(-b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c)/(b
*cos(2*d*x + 2*c) + b)) + sqrt(-a + b)*log(-(a - b)*cos(2*d*x + 2*c) + sqrt(-a + b)*sqrt(((a - b)*cos(2*d*x +
2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c) + b))/d, -(sqrt(a - b)*arctan(-sqrt(a - b)*sqrt(((a - b
)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c)/((a - b)*cos(2*d*x + 2*c) + a - b)) - sqr
t(-b)*arctan(sqrt(-b)*sqrt(((a - b)*cos(2*d*x + 2*c) - a - b)/(cos(2*d*x + 2*c) - 1))*sin(2*d*x + 2*c)/(b*cos(
2*d*x + 2*c) + b)))/d]

Sympy [F]

\[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\int \sqrt {a + b \cot ^{2}{\left (c + d x \right )}}\, dx \]

[In]

integrate((a+b*cot(d*x+c)**2)**(1/2),x)

[Out]

Integral(sqrt(a + b*cot(c + d*x)**2), x)

Maxima [F(-2)]

Exception generated. \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\text {Exception raised: ValueError} \]

[In]

integrate((a+b*cot(d*x+c)^2)^(1/2),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(b-a>0)', see `assume?` for mor
e details)Is

Giac [F(-2)]

Exception generated. \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\text {Exception raised: TypeError} \]

[In]

integrate((a+b*cot(d*x+c)^2)^(1/2),x, algorithm="giac")

[Out]

Exception raised: TypeError >> an error occurred running a Giac command:INPUT:sage2:=int(sage0,sageVARx):;OUTP
UT:Error: Bad Argument Type

Mupad [F(-1)]

Timed out. \[ \int \sqrt {a+b \cot ^2(c+d x)} \, dx=\int \sqrt {b\,{\mathrm {cot}\left (c+d\,x\right )}^2+a} \,d x \]

[In]

int((a + b*cot(c + d*x)^2)^(1/2),x)

[Out]

int((a + b*cot(c + d*x)^2)^(1/2), x)